import "dart:developer";
import "package:sports_new/entity/expert/zq_hot_expert_entity.dart";
import "package:sports_new/entity/expert/expert_hot_entity.dart";
import "package:sports_new/entity/expert/expert_record_entity.dart";
import "package:sports_new/entity/expert/expert_search_entity.dart";
import "package:sports_new/entity/expert/expert_top_entity.dart";
import "package:sports_new/entity/expert/plan_Info_entity.dart";
import "package:sports_new/entity/expert/subs_article_entity.dart";
import "package:sports_new/entity/expert/subs_article_list_entity.dart";
import "package:sports_new/entity/home/news_class_entity.dart";
import "package:sports_new/entity/home/user_detail_entity.dart";
import "package:sports_new/entity/match/expert_views_entity.dart";
import "package:sports_new/server/http/dio_utils.dart";
import "package:sports_new/utils/user.dart";
import "../../entity/expert/expert_rate_entity.dart";
import "../../entity/expert/plan_filter_entity.dart";
import "../../entity/expert/plan_form/plan_form_detail_entity.dart";
import "../../entity/expert/plan_form/plan_form_entity.dart";
import "../../entity/expert/plan_form/plan_form_list_entity.dart";
import "../../entity/expert/plan_pack/plan_pack_entity.dart";
import "../../entity/home/subs_list_entity.dart";
import "../../entity/live/live_plan_entity.dart";
import "../api_dir.dart";

class ExpertApi {
  //方案详情
  static Future<PlanInfoEntity> getPlanInfo(int planId) async {
    try {
      final response =
          await DioUtils.post("/${ApiDir.plan}/app-plan-do/planInfo", params: {
        "expertId": "",
        "expertType": "1",
        "planId": "$planId",
        "userId": "${User.auth?.userId}"
      });
      return PlanInfoEntity.fromJson(response.data["d"]);
    } catch (err) {
      return PlanInfoEntity();
    }
  }

  ///专家推荐
  static Future<List<HotExpertEntity>?> getExpertHot(int id) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-expert-do/expertTop",
        params: id);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<HotExpertEntity> data = result.data["d"]
          .map<HotExpertEntity>((e) => HotExpertEntity.fromSeparateValue(e))
          .toList();
      return data;
    }
    return null;
  }

  ///资讯专家推荐
  static Future<List<NewsExpertHotEntity>?> getNewsExpertHot() async {
    final result = await DioUtils.post(
        "/${ApiDir.info}/info-collect-do/infoUserTop",
        params: 0);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<NewsExpertHotEntity> data = result.data["d"]
          .map<NewsExpertHotEntity>((e) => NewsExpertHotEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///人气专家推荐
  static Future<List<HotExpertEntity>?> getRenqiExpertHot(int sportsId) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-rank-do/popularityExpert",
        params: {"sportsId": sportsId});
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<HotExpertEntity> data = result.data["d"]
          .map<HotExpertEntity>((e) => HotExpertEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///足球专家推荐
  static Future<List<HotExpertEntity>?> getZqExpertHot(
      int type, int sportsId) async {
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/expertHot",
        params: {"searchType": type, "sportsId": sportsId});
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<HotExpertEntity> data = result.data["d"]
          .map<HotExpertEntity>((e) => HotExpertEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///专家历史方案
  static Future<List<PlanEntity>?> getPlanHistory(
      String? expertId, int? sportsId, int page, int pageSize) async {
    final params = {
      "data": {"expertId": expertId, "sportsId": sportsId, "isFree": 1},
      "page": page,
      "pageSize": pageSize
    };
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-plan-do/planHistory",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<PlanEntity> data = result.data["d"]["rows"]
          .map<PlanEntity>((e) => PlanEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///专家最新方案
  static Future<List<PlanEntity>?> getExpertNewViews(
      String? expertId, int? sportsId) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-plan-do/expertLastPlan",
        params: {"expertId": expertId, "sportsId": sportsId, "isFree": 1});
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<PlanEntity> data = result.data["d"]
          .map<PlanEntity>((e) => PlanEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///专家战绩
  static Future<ExpertRecordEntity?> getExpertRecord(
      String? id, int? sportsId) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-expert-do/expertRecord",
        params: {"expertId": id, "sportsId": sportsId});
    if (result.statusCode == 200 && result.data["c"] == 200) {
      if (result.data["d"] != null) {
        final data = ExpertRecordEntity.fromJson(result.data["d"]);
        return data;
      }
    }
    return null;
  }

  ///订阅专家列表
  static Future<List<SubsListEntity>?> getSubsList(
      int order, int page, int size) async {
    try {
      final result =
          await DioUtils.post("/${ApiDir.plan}/app-idea/expertList", params: {
        "data": {"orderBy": order},
        "page": page,
        "pageSize": size,
      });
      if (result.statusCode == 200 && result.data["c"] == 200) {
        List<SubsListEntity> data = result.data["d"]
            .map<SubsListEntity>((e) => SubsListEntity.fromJson(e))
            .toList();
        return data;
      }
    } catch (e) {
      return [];
    }
    return [];
  }

  ///订阅专家详情
  static Future<SubsListEntity?> getSubsDetail(String id, {int? roomId}) async {
    final params = {"id": id, "roomId": roomId};
    final result = await DioUtils.post("/${ApiDir.plan}/app-idea/ideaInfo",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      SubsListEntity? data = SubsListEntity.fromJson(result.data["d"]);
      return data;
    }
    return null;
  }

  ///订阅文章列表
  static Future<List<ArticleDetail>?> getSubsArticleList(
      String expertId, int page, int pageSize) async {
    final params = {
      "data": {"expertId": expertId},
      "page": page,
      "pageSize": pageSize
    };
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-idea/expertIdeaList",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ArticleDetail> data = result.data["d"]["rows"]
          .map<ArticleDetail>((e) => ArticleDetail.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///专家订阅文章
  static Future<SubsArticleEntity> getArticle(int ideaId) async {
    final params = {
      "ideaId": ideaId,
    };
    final result = await DioUtils.post("/${ApiDir.plan}/app-idea/ideaDetail",
        params: params, showLoading: true);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      SubsArticleEntity? data = SubsArticleEntity.fromJson(result.data["d"]);
      return data;
    }
    return SubsArticleEntity();
  }

  ///专家热门方案
  static Future<List<PlanEntity>> getHotPlan(
      int page, int size, int searchType, sportsId,
      {Map<int, Filter>? type}) async {
    final params = {
      "data": {
        "searchType": searchType,
        "sportsId": sportsId,
        if (type?.containsKey(1) == true) "kind": type?[1]?.type,
        if (type?.containsKey(2) == true) "playType": type?[2]?.type,
        if (type?.containsKey(3) == true) "leagueId": type?[3]?.type,
      },
      "page": page,
      "pageSize": size
    };
    final focus = {"userId": User.auth?.userId, "sportsId": sportsId};
    try {
      final result = await DioUtils.post(
          "/${ApiDir.plan}/app-plan-do/${searchType == 0 ? "lastPlanFocus" : "lastPlanHotAll"}",
          params: searchType == 0 ? focus : params);
      if (result.statusCode == 200 && result.data["c"] == 200) {
        if (searchType == 0) {
          List<PlanEntity> data = result.data["d"]["rows"]
              .map<PlanEntity>((e) => PlanEntity.fromJson(e))
              .toList();
          return data;
        } else {
          List<PlanEntity> data = result.data["d"]
              .map<PlanEntity>((e) => PlanEntity.fromJson(e))
              .toList();
          return data;
        }
      }
    } catch (e) {
      return [];
    }
    return [];
  }

  ///专家人气方案
  static Future<List<PlanEntity>> getRenqiPlan(int page, int size, sportsId,
      {int? matchId}) async {
    final params = {
      "data": {
        if (matchId != null) "matchId": matchId,
        "sportsId": sportsId,
      },
      "page": page,
      "pageSize": size
    };
    // final focus = {"userId": User.auth?.userId, "sportsId": sportsId};
    try {
      final result = await DioUtils.post(
          "/${ApiDir.plan}/app-plan-do/popularityPlan",
          params: params);
      if (result.statusCode == 200 && result.data["c"] == 200) {
        // if (searchType == 0) {
        //   List<PlanEntity> data = result.data["d"]["rows"]
        //       .map<PlanEntity>((e) => PlanEntity.fromJson(e))
        //       .toList();
        //   return data;
        // } else {
        List<PlanEntity> data = result.data["d"]
            .map<PlanEntity>((e) => PlanEntity.fromJson(e))
            .toList();
        return data;
        // }
      }
    } catch (e) {
      return [];
    }
    return [];
  }

  ///全部专家
  static Future<List<PlanEntity>?> getExpertAll(
      int page, int size, int type, String input) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-expert-do/qdsExpertList",
        params: {
          "data": {"type": type, "expertName": input},
          "page": page,
          "pageSize": size
        });
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<PlanEntity> data = result.data["d"]["rows"]
          .map<PlanEntity>((e) => PlanEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///查询专家
  static Future<List<ExpertSearchEntity>?> getExpert(String input) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-expert-do/qdsExpertList",
        params: {"expertName": input, "userId": User.info?.id});
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ExpertSearchEntity> data = result.data["d"]
          .map<ExpertSearchEntity>((e) => ExpertSearchEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///命中榜条件
  static Future<List<NewsClassEntity>?> getMingzhongCondition() async {
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/his");
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<NewsClassEntity> data = result.data["d"]
          .map<NewsClassEntity>((e) => NewsClassEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///回报榜条件
  static Future<List<NewsClassEntity>?> getHuibaoCondition() async {
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/profits");
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<NewsClassEntity> data = result.data["d"]
          .map<NewsClassEntity>((e) => NewsClassEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///人气榜条件
  static Future<List<NewsClassEntity>?> getRenqiCondition() async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-rank-do/popularityRankTimeType");
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<NewsClassEntity> data = result.data["d"]
          .map<NewsClassEntity>((e) => NewsClassEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///人气榜
  static Future<List<ExpertTopEntity>?> getRenqiTop(
      int id, int sportsId) async {
    final params = {"timeTypeId": id, "sportsId": sportsId};
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-rank-do/popularityRank",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ExpertTopEntity> data = result.data["d"]
          .map<ExpertTopEntity>((e) => ExpertTopEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///命中榜
  static Future<List<ExpertTopEntity>?> getHitTop(int id, int sportsId) async {
    final params = {"day": id, "sportsId": sportsId};
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/hitRank",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ExpertTopEntity> data = result.data["d"]
          .map<ExpertTopEntity>((e) => ExpertTopEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///回报榜
  static Future<List<ExpertTopEntity>?> getProfitTop(
      int id, int sportsId) async {
    final params = {"planCnt": id, "sportsId": sportsId};
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/profitRank",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ExpertTopEntity> data = result.data["d"]
          .map<ExpertTopEntity>((e) => ExpertTopEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///连红榜
  static Future<List<ExpertTopEntity>?> getRedTop(int id, int sportsId) async {
    final params = {"red": id, "sportsId": sportsId};
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/redRank",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ExpertTopEntity> data = result.data["d"]
          .map<ExpertTopEntity>((e) => ExpertTopEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///赛事榜赛事
  static Future<List<NewsClassEntity>?> getTopLeagues(int sportsId) async {
    final params = {"id": sportsId};
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/leagues",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<NewsClassEntity> data = result.data["d"]
          .map<NewsClassEntity>((e) => NewsClassEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///赛事榜
  static Future<List<ExpertTopEntity>?> getLeagueTop(
      int id, int sportsId, int leagueId) async {
    final params = {"type": id, "sportsId": sportsId, "typeKey": leagueId};
    final result = await DioUtils.post("/${ApiDir.plan}/app-rank-do/leagueRank",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ExpertTopEntity> data = result.data["d"]
          .map<ExpertTopEntity>((e) => ExpertTopEntity.fromJson(e))
          .toList();
      return data;
    }
    return null;
  }

  ///方案筛选
  static Future<PlanFilterEntity> getMenu() async {
    final result =
        await DioUtils.post("/${ApiDir.plan}/app-plan-do/planSearchParams");
    if (result.statusCode == 200 && result.data["c"] == 200) {
      PlanFilterEntity? data = PlanFilterEntity.fromJson(result.data["d"]);
      return data;
    }
    return PlanFilterEntity();
  }

  ///专家擅长联赛
  static Future<List<LeagueTop>?> getExpertLeagues(String userId) async {
    final params = {"id": userId, "type": 1};
    final result = await DioUtils.post(
        "/${ApiDir.user}/app-user-home/leagueTopItem",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<LeagueTop> data = result.data["d"]
          .map<LeagueTop>((e) => LeagueTop.fromJson(e))
          .toList();
      return data;
    }
    return [];
  }

  ///比赛详情专家推荐
  static Future<List<HotExpertEntity>> getMatchExpertHot(
      int? leagueId, int sportsId) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-plan-match-do/expertTopWithLeague",
        params: {"leagueId": leagueId, "sportsId": sportsId});
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<HotExpertEntity> data = result.data["d"]
          .map<HotExpertEntity>((e) => HotExpertEntity.fromJsonMatch(e))
          .toList();
      return data;
    }
    return [];
  }

  ///专家命中率折线图
  static Future<List<ExpertRateEntity>?> getExpertRate(
      String? expertId, int sportsId) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-expert-do/matchChart",
        params: {"expertId": expertId, "sportsId": sportsId});
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<ExpertRateEntity> data = result.data["d"]
          .map<ExpertRateEntity>((e) => ExpertRateEntity.fromJson(e))
          .toList();
      return data;
    }
    return [];
  }

  ///专家擅长联赛方案
  static Future<List<PlanEntity>> getExpertLeaguePlan(
      String? expertId, int? sportsId, int? leagueId, int page) async {
    var params = {
      "data": {
        "expertId": expertId,
        "sportsId": sportsId,
        "leagueId": leagueId,
        "expertType": sportsId
      },
      "page": page,
      "pageSize": 15
    };
    final result = await DioUtils.post("/${ApiDir.plan}/app-plan-do/planRecent",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<PlanEntity> data = result.data["d"]?["rows"]
          .map<PlanEntity>((e) => PlanEntity.fromJson(e))
          .toList();
      return data;
    }
    return [];
  }

  //咨询推荐方案
  static Future<List<PlanEntity>> getNewsPlan(
      int? matchId, int? sportsId) async {
    var params = {
      "matchId": matchId,
      "sportsId": sportsId,
    };
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-plan-match-do/expertTopWithNews",
        params: params);
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<PlanEntity> data = result.data["d"]
          .map<PlanEntity>((e) => PlanEntity.fromJson(e))
          .toList();
      return data;
    }
    return [];
  }

  ///比赛详情方案
  static Future<ExpertViewsEntity?> getMatchViews(
      String? matchId, int page, int size, int index, int sportsId) async {
    var i = index;
    List<String> url = [
      "matchPlanFocus",
      "matchPlan",
      "matchPlanFree",
      "matchPlanBack",
      "matchPlanRed"
    ];
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-plan-match-do/${url[i]}",
        params: {
          "page": page,
          "pageSize": size,
          "data": {
            "matchId": matchId,
            "userId": i == 0 ? User.auth?.userId : "",
            "sportsId": "$sportsId"
          }
        });
    if (result.statusCode == 200 && result.data["c"] == 200) {
      final data = ExpertViewsEntity.fromJson(result.data["d"]);
      return data;
    }
    return null;
  }

  static Future<LivePlanEntity> getLivePlan(String? matchId, String? expertId,
      int sportsId, int page, int pageSize) async {
    final result = await DioUtils.post(
      "/${ApiDir.plan}/app-plan-do/lastPlanHotWithLive",
      params: {
        "page": page,
        "pageSize": pageSize,
        "data": {
          "matchId": matchId,
          "expertId": expertId,
          "sportsId": "$sportsId"
        }
      },
    );
    if (result.statusCode == 200 && result.data["c"] == 200) {
      LivePlanEntity data = LivePlanEntity.fromJson(result.data["d"]);
      return data;
    }
    return LivePlanEntity();
  }

  static Future<List<PlanEntity>> getLivePlanOther(String? matchId,
      String? expertId, int sportsId, int page, int pageSize) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-plan-do/lastPlanHotWithLive",
        params: {
          "page": page,
          "pageSize": pageSize,
          "data": {
            "matchId": matchId,
            "expertId": expertId,
            "sportsId": "$sportsId"
          }
        });
    if (result.statusCode == 200 && result.data["c"] == 200) {
      List<PlanEntity> data = result.data["d"]?["other"]
          .map<PlanEntity>((e) => PlanEntity.fromJson(e))
          .toList();
      return data;
    }
    return [];
  }

  //计划单列表
  static Future<List<PlanForm>> getPlanForm(int? stage, int type) async {
    final result =
        await DioUtils.post("/${ApiDir.plan}/app-plan-list/index", params: {
      "stage": stage,
      "type": type,
    });
    if (result.statusCode == 200 && result.data['c'] == 200) {
      try {
        List<PlanForm> data = result.data['d']
            .map<PlanForm>((e) => PlanForm.fromJson(e))
            .toList();
        return data;
      } catch (e) {
        log(e.toString());
        return [];
      }
    }
    return [];
  }

  //计划单详情
  static Future<PlanFormDetail?> getPlanFormDetail(int? issueId) async {
    final result = await DioUtils.post("/${ApiDir.plan}/app-plan-list/detail",
        params: {"issueId": issueId});
    if (result.statusCode == 200 && result.data['c'] == 200) {
      try {
        final data = PlanFormDetail.fromJson(result.data['d']);
        return data;
      } catch (e) {
        log(e.toString());
        return null;
      }
    }
    return null;
  }

  //计划单列表
  static Future<PlanFormList?> getPlanFormList(String expertId) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-plan-list/listByExpert",
        params: {"expertId": expertId});
    if (result.statusCode == 200 && result.data['c'] == 200) {
      try {
        final data = PlanFormList.fromJson(result.data['d']);
        return data;
      } catch (e) {
        log(e.toString());
        return null;
      }
    }
    return null;
  }

  //专家批量关注列表
  static Future<List<HotExpertEntity>> getSuggestExpert(
      String? expertId, int? page, int type) async {
    final result = await DioUtils.post(
        "/${ApiDir.plan}/app-expert-do/expertBatchTop",
        params: {"expertId": expertId, "page": page, "type": type});
    try {
      if (result.statusCode == 200 && result.data['c'] == 200) {
        List<HotExpertEntity> data = result.data['d']
            .map<HotExpertEntity>((e) => HotExpertEntity.fromSeparateValue(e))
            .toList();
        return data;
      }
    } catch (e) {
      log(e.toString());
      return [];
    }
    return [];
  }

  //方案套餐列表
  static Future<List<PlanPackEntity>> getPlanPack({String? expertId}) async {
    try {
      final result = await DioUtils.post(
          "/${ApiDir.plan}/app-pl-package-do/packageArray",
          params: {"expertId": expertId});
      if (result.statusCode == 200 && result.data['c'] == 200) {
        List<PlanPackEntity> data = result.data['d']
            .map<PlanPackEntity>((e) => PlanPackEntity.fromJson(e))
            .toList();
        return data;
      }
    } catch (e) {
      log(e.toString());
    }
    return [];
  }

  //方案历史套餐列表
  static Future<List<PlanPackEntity>> getPlanPackHistory(
      int? page, int? pageSize,
      {String? expertId}) async {
    try {
      final result = await DioUtils.post(
          "/${ApiDir.plan}/app-pl-package-do/historyArray",
          params: {
            "page": page,
            "pageSize": pageSize,
            "data": {
              "expertId": expertId,
            }
          });
      if (result.statusCode == 200 && result.data['c'] == 200) {
        List<PlanPackEntity> data = result.data['d']['rows']
            .map<PlanPackEntity>((e) => PlanPackEntity.fromJson(e))
            .toList();
        return data;
      }
    } catch (e) {
      log(e.toString());
    }
    return [];
  }

  //方案详情
  static Future<PlanPackEntity> getPlanPackDetail(int packId) async {
    try {
      final response = await DioUtils.post(
          "/${ApiDir.plan}/app-pl-package-do/packageInfo",
          params: {"id": packId});
      return PlanPackEntity.fromJson(response.data["d"]);
    } catch (err) {
      return PlanPackEntity();
    }
  }
}
